<?php
/*********************************************
  CPG Dragonfly™ CMS
  ********************************************
  Copyright © 2004 - 2007 by CPG-Nuke Dev Team
  http://dragonflycms.org

  Dragonfly is released under the terms and conditions
  of the GNU GPL version 2 or any later version
**********************************************/
if (!defined('CPG_NUKE')) { exit; }

$currentlang = Dragonfly::getKernel()->L10N->lng;

Dragonfly::getKernel()->L10N->load('main');
define('_LANGCODE', Dragonfly::getKernel()->L10N->lng);
if (!defined('_CHARSET')) { define('_CHARSET', Dragonfly::CHARSET); }

function get_langcode($thislang)
{
	trigger_deprecated("use Dragonfly::getKernel()->L10N->lng.");
	return Dragonfly::getKernel()->L10N->lng;
}

function get_lang($module)
{
	trigger_deprecated("use Dragonfly::getKernel()->L10N->load().");
	Dragonfly::getKernel()->L10N->load($module);
}

function lang_selectbox($current, $fieldname='alanguage', $all=true, $return_list=false)
{
	if ($return_list) {
		trigger_deprecated("use Dragonfly::getKernel()->L10N->getActiveList().");
		$languages = array();
		foreach (Dragonfly::getKernel()->L10N->getActiveList() as $lng) {
			$languages[] = $lng['value'];
		}
		return $languages;
	}

	$content = '<select name="'.$fieldname.'" id="'.$fieldname.'">';
	if ($all) {
		$content .= '<option value=""'.($current ? '' : ' selected="selected"').'>'._ALL."</option>\n";
	}
	foreach (Dragonfly::getKernel()->L10N->getActiveList() as $lng)
	{
		$content .= '<option value="'.$lng['value'].'"'.(($lng['value'] == $current) ? ' selected="selected"' : '').'>'.$lng['label']."</option>\n";
	}
	return $content.'</select>';
}
